import request from '@/server/request';

export function commonRequest(data, url, method = 'post', headers = {}) {
  const requestData = {
    url,
    method,
    headers
  };

  if (method === 'post') {
    requestData.data = data;
  } else {
    requestData.params = data;
  }

  return request(requestData);
}

// 获取人员
export function getUserPage(data) {
  return request({
    url: 'user/page',
    method: 'post',
    data
  });
}

export function submitModel(data) {
  return request({
    url: 'modelForm/submitModel',
    method: 'post',
    data
  });
}

export function findModelFormTableInfo(params) {
  return request({
    url: 'modelForm/findModelFormTableInfo',
    method: 'get',
    params
  });
}

export function findModelInfoByFormGuid(params) {
  return request({
    url: 'modelForm/findModelInfoByFormGuid',
    method: 'get',
    params
  });
}

export function queryHeaderByTableId(params) {
  return request({
    url: 'dynamicForm/queryHeaderByTableId',
    method: 'get',
    params
  });
}

export function myReceivedList(params) {
  return request({
    url: 'modelForm/myReceived/list',
    method: 'get',
    params
  });
}

export function getInstanceOpinion(params) {
  return request({
    url: 'formTask/instance/getInstanceOpinion',
    method: 'get',
    params
  });
}

export function handleNodeFreeSelectUser(data) {
  return request({
    url: 'formTask/task/handleNodeFreeSelectUser',
    method: 'post',
    data
  });
}

export function submitApprove(data) {
  return request({
    url: 'modelForm/submitApprove',
    method: 'post',
    data
  });
}

export function updCommentStatus(data) {
  return request({
    url: 'comment/updCommentStatus',
    method: 'post',
    data
  });
}

export function getCanBackHistoryNodes(data) {
  return request({
    url: 'formTask/task/getCanBackHistoryNodes',
    method: 'post',
    headers: {
      notShowMessage: true
    },
    data
  });
}

export function listComment(data) {
  return request({
    url: 'comment/listComment',
    method: 'post',
    headers: {
      notShowMessage: true
    },
    data
  });
}

export function addComment(data) {
  return request({
    url: 'comment/addComment',
    method: 'post',
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    data
  });
}

export function flowImageInfo(params) {
  return request({
    url: 'formTask/instance/getFlowImageInfo',
    method: 'get',
    params
  });
}

export function getKeyByModelId(params) {
  return request({
    url: 'modelForm/getKeyByModelId',
    method: 'get',
    params
  });
}

